<admintpl file="header" />
	<style>
		.center {
			text-align: center!important;
		}
	</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="javascript:;">{:L('PORTAL_ADMINPOST_INDEX')}</a></li>
			<li><a href="{:U('AdminPost/add',array('term'=>empty($term['term_id'])?'':$term['term_id']))}" target="_self">{:L('PORTAL_ADMINPOST_ADD')}</a></li>
		</ul>
		<form class="well form-search" method="post" action="{:U('AdminPost/index')}">
			分类： 
			<select name="category" style="width: 120px;">
				<option value='0'>全部</option>
				<volist name="post_categorys" id="vo">
					<option value="{$vo.id}" {$formget['category'] == $vo['id'] ? 'selected' : ''}>{$vo.name}</option>
				</volist>
			</select>&nbsp;
            作者：
            <input type="text" name="author" style="width: 150px;" value="{$formget.author|default=''}" placeholder="请输入作者...">
			时间：
			<input type="text" name="start_time" class="js-datetime" value="{$formget.start_time|default=''}" style="width: 120px;" autocomplete="off">-
			<input type="text" class="js-datetime" name="end_time" value="{$formget.end_time|default=''}" style="width: 120px;" autocomplete="off"> &nbsp; &nbsp;
			关键字： 
			<input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword|default=''}" placeholder="请输入关键字...">
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:U('AdminPost/index')}">清空</a>
		</form>
		<form class="js-ajax-form" action="" method="post">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">{:L('SORT')}</th>
						<th width="50">ID</th>
						<th>{:L('TITLE')}</th>
						<th width="50">{:L('AUTHOR')}</th>
						<th width="50">{:L('HITS')}</th>
						<th width="50">{:L('COMMENT_COUNT')}</th>
						<th width="160">{:L('KEYWORDS')}/{:L('SOURCE')}/{:L('ABSTRACT')}/{:L('THUMBNAIL')}</th>
						<th width="100">{:L('PUBLISH_DATE')}</th>
						<th width="50">{:L('STATUS')}</th>
						<th width="100">{:L('ACTIONS')}</th>
					</tr>
				</thead>
				<foreach name="posts" item="vo">
				<tr>
					<td><input data-id="{$vo.id}" class="input input-order" type="text" size="5" value="{$vo.post_order}"></td>
                    <td>{$vo.id}</td>
					<td>{$vo.post_title}</td>
					<td>{$vo.post_author_name|default=$vo['user_nicename']}</td>
					<td class="center">{$vo.post_hits}</td>
					<td class="center">{$vo.comment_count}</td>
					<td class="center">
						<notempty name="vo.post_keywords">
							<i class="fa fa-check fa-fw"></i>
						<else/>
							<i class="fa fa-close fa-fw"></i> 
						</notempty>
						<notempty name="vo.post_source">
							<i class="fa fa-check fa-fw"></i>
						<else/>
							<i class="fa fa-close fa-fw"></i> 
						</notempty>
						<notempty name="vo.post_excerpt">
							<i class="fa fa-check fa-fw"></i>
						<else/>
							<i class="fa fa-close fa-fw"></i> 
						</notempty>
						
						<php>$smeta=json_decode($vo['smeta'],true);</php>
						<notempty name="smeta.thumb">
							<a href="javascript:parent.image_preview_dialog('{:sp_get_image_preview_url($smeta['thumb'])}');">
								<i class="fa fa-photo fa-fw"></i>
							</a>
						</notempty>
					</td>
					<td>{:date('Y-m-d H:i',strtotime($vo['post_date']))}</td>
					<td>
						<php>$status = array('0' => '未审核', '1' => '正常', '2' => '审核未通过', '4' => '草稿')</php>
						{$status[$vo['post_status']]}
					</td>
					<td>
						<a href="{:U('AdminPost/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a> | 
						<a href="{:U('AdminPost/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:L('DELETE')}</a>
						<a target="_blank" href="{:U('Portal/Article/article_info',array('id'=>$vo['id']))}">预览</a>
					</td>
				</tr>
				</foreach>
			</table>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
		$(document).ready(function () {
			$('body').delegate('.input-order', 'change', function () {
			    var order 	= $(this).val();
			    var id 		= $(this).attr('data-id');
			    $.get("{:U('AdminPost/change_post_order')}", {id : id, order : order}, function (data) {
					if (data.status) {
					    window.location.reload();
					}
                })
            })
        })
	</script>
</body>
</html>